"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
const fs = __importStar(require("fs"));
const component = {
    name: 'add_panel',
    props: {
        nodeData: Object,
        lf: Object || String
    },
    emits: ['addNodeFinish'],
    template: fs.readFileSync(`${__dirname}/add_panel.html`, "utf-8"),
    style: fs.readFileSync(`${__dirname}/add_panel.css`, "utf-8"),
    methods: {
        $_addNode(item) {
            const { lf, nodeData } = this.$props;
            const { id, x, y } = nodeData;
            const nextNode = lf.addNode({
                type: item.type,
                x: x + 150,
                y: y + 150
            });
            const nextId = nextNode.id;
            lf.addEdge({ sourceNodeId: id, targetNodeId: nextId });
            this.$emit('addNodeFinish');
        },
        $_addTempalte() {
            const { lf, nodeData } = this.$props;
            const { id, x, y } = nodeData;
            const timeNode = lf.addNode({
                type: 'download',
                x,
                y: y + 150
            });
            const userNode = lf.addNode({
                type: 'user',
                x: x + 150,
                y: y + 150
            });
            const pushNode = lf.addNode({
                type: 'push',
                x: x + 150,
                y: y + 300,
                properties: {}
            });
            const endNode = lf.addNode({
                type: 'end',
                x: x + 300,
                y: y + 150
            });
            const endNode2 = lf.addNode({
                type: 'end',
                x: x + 300,
                y: y + 300
            });
            lf.addEdge({ sourceNodeId: id, targetNodeId: timeNode.id });
            lf.addEdge({ sourceNodeId: timeNode.id, targetNodeId: userNode.id });
            lf.addEdge({
                sourceNodeId: userNode.id,
                targetNodeId: endNode.id,
                endPoint: { x: x + 280, y: y + 150 },
                text: {
                    value: 'Y',
                    x: x + 230,
                    y: y + 140
                }
            });
            lf.addEdge({
                sourceNodeId: userNode.id,
                targetNodeId: pushNode.id,
                text: {
                    value: 'N',
                    x: x + 160,
                    y: y + 230
                }
            });
            lf.addEdge({ sourceNodeId: pushNode.id, targetNodeId: endNode2.id, endPoint: { x: x + 280, y: y + 300 } });
            this.$emit('addNodeFinish');
        }
    },
    data() {
        return {
            nodeList: [
                {
                    type: 'user',
                    label: '用户'
                },
                {
                    type: 'push',
                    label: '推送'
                }
            ]
        };
    },
    watch: {},
    created() { },
    mounted() {
    },
};
module.exports = component;
